﻿package plugin.duanzao.handler
{
    import cmd.*;
    import com.core.*;
    import com.sh.game.global.*;
    import com.sh.game.util.*;
    import consts.*;
    import flash.external.*;
    import flash.geom.*;
    import manager.*;
    import plugin.npcDialog.*;
    import pluginfw.nio.imsg.*;
    import view.*;
    import view.message.*;
    import view.uilt.*;

    public class QiangHuaHandler extends Object implements IGroupHandler
    {

        public function QiangHuaHandler()
        {
            return;
        }// end function

        public function dealSimpleMessage(param1:ISimpleMessage) : void
        {
            var tooltype:int;
            var itemconfig:Object;
            var x:int;
            var arr:Array;
            var option:Object;
            var item:Object;
            var cfgitem:Object;
            var hec:Object;
            var bj:int;
            var message:* = param1;
            switch(message.getCmd())
            {
                case CMDQiangHua.Init:
                {
                    ModelProxy.change("qianghua", "init", message.getParam());
                    break;
                }
                case CMDQiangHua.QiangHua:
                {
                    ModelProxy.change("qianghua", "qianghua", message.getParam());
                    break;
                }
                case CMDQiangHua.ZS:
                {
                    ModelProxy.change("qianghua", "zs", message.getParam());
                    break;
                }
                case CMDQiangHua.FuMo:
                {
                    ModelProxy.change("qianghua", "fumo", message.getParam());
                    break;
                }
                case CMDQiangHua.XiLian:
                {
                    ModelProxy.change("qianghua", "xilian", message.getParam());
                    break;
                }
                case CMDQiangHua.ChangeItem:
                {
                    ModelProxy.change("qianghua", "changeitem", message.getParam());
                    break;
                }
                case CMDQiangHua.Error:
                {
                    ModelProxy.change("movetips", "error", message.getParam());
                    ModelProxy.change("data", "qhflag", false);
                    ModelProxy.change("qianghua", "setvisible", null);
                    break;
                }
                case CMDQiangHua.Zyqh:
                {
                    ModelProxy.change("qianghua", "zyqhback", null);
                    option = ModelProxy.getValue("localCache", "option");
                    if (option && option.offbasesound != 1)
                    {
                        ModelProxy.change("main", "playsound", SoundType.BTN_QIANGHUAZY);
                    }
                    break;
                }
                case CMDQiangHua.Qqsbuzu:
                {
                    ModelProxy.change("data", "qhflag", false);
                    ModelProxy.change("qianghua", "setvisible", null);
                    item = message.getParam();
                    cfgitem = ConfigDictionary.data.item[item.itemid];
                    item.icon = cfgitem.icon;
                    item.name1 = cfgitem.name;
                    Alert2.show(item.name1 + "不足前往购买", "", ["确认", "取消"], function (param1:int, param2:Object) : void
            {
                if (param1 == 0)
                {
                    DialogMgr.instance.open(AppDialog.SURE_BUY_STORE, item);
                }
                return;
            }// end function
            );
                    break;
                }
                case CMDQiangHua.YBbuzu:
                {
                    Alert2.show("元宝不足前往充值", "", ["确认", "取消"], function (param1:int, param2:Object) : void
            {
                if (param1 == 0)
                {
                    if (!ItemUilt.canpay)
                    {
                        ModelProxy.change("movetips", "error", "功能尚未开放，敬请期待");
                        return;
                    }
                    ExternalInterface.call("topay");
                }
                return;
            }// end function
            );
                    ModelProxy.change("data", "qhflag", false);
                    ModelProxy.change("qianghua", "setvisible", null);
                    break;
                }
                case CMDQiangHua.Qqsbuzupc:
                {
                    ModelProxy.change("qianghua", "Qqsbuzupc", message.getParam());
                    break;
                }
                case CMDQiangHua.Zssbuzupc:
                {
                    ModelProxy.change("qianghua", "Zssbuzupc", message.getParam());
                    break;
                }
                case CMDQiangHua.Appraisal:
                {
                    ModelProxy.change("jianding", "appraisal", message.getParam());
                    break;
                }
                case CMDQiangHua.DoCompound:
                {
                    tooltype = message.getParam();
                    if (tooltype >= 1 && tooltype <= 3)
                    {
                        ModelProxy.change("qianghua", "reshow", null);
                        ModelProxy.change("qianghua", "updateCompound", null);
                    }
                    else if (tooltype == 4)
                    {
                        ModelProxy.change("movetips1", "error", MColor.getHMTL("恭喜您熔铸成功，祝你好运！", 6));
                    }
                    else if (tooltype == 0)
                    {
                        ModelProxy.change("yitianpidi", "updatenew", null);
                    }
                    break;
                }
                case CMDQiangHua.DoCompound2:
                {
                    itemconfig = ConfigDictionary.data.newsrl;
                    var _loc_3:int = 0;
                    var _loc_4:* = itemconfig;
                    while (_loc_4 in _loc_3)
                    {
                        
                        hec = _loc_4[_loc_3];
                        bj = itemconfig[message.getParam()].npctype;
                    }
                    x = int((GlobalLayer.instance.root.stageWidth - 700) / 2);
                    if (bj == 1)
                    {
                        ModelProxy.change("npcdialog", "update", {type:NpcDialogType.RLhecheng, data:null});
                    }
                    else if (bj == 2)
                    {
                        ModelProxy.change("npcdialog", "update", {type:NpcDialogType.shenzhuangHCPL, data:null});
                    }
                    else if (bj == 3)
                    {
                        ModelProxy.change("npcdialog", "update", {type:NpcDialogType.RxhcPL, data:null});
                    }
                    break;
                }
                case CMDQiangHua.DoCompound3:
                {
                    ModelProxy.change("movetips1", "error", MColor.getHMTL("合成成功获得" + message.getParam(), 6));
                    ModelProxy.change("qianghua", "sucess", 2);
                    break;
                }
                case CMDQiangHua.DoError3:
                {
                    arr = message.getParam();
                    Alert.show("将（" + MColor.getHMTL(arr[0], 7) + "）升级到（" + MColor.getHMTL(arr[1], 26) + "），需要将（" + MColor.getHMTL(arr[0], 7) + "）强化到+" + MColor.getHMTL(arr[2], 7) + "<br>强化值在升级的时候完美继承下去。<br>强化可以获得大量属性!", "升级失败", ["前往强化", "取消"], function (param1:int, param2:Object) : void
            {
                var _loc_3:Point = null;
                if (param1 == 0)
                {
                    PluginManager.instance.closePlugin("qianghua");
                    _loc_3 = UIGlobel.pointsDic["qianghua"];
                    PluginManager.instance.changePlugin("qianghua", new Point(_loc_3.x, _loc_3.y), 1, null);
                }
                return;
            }// end function
            );
                    break;
                }
                case CMDQiangHua.Decompose:
                {
                    ModelProxy.change("qianghua", "sucess", 3);
                    break;
                }
                default:
                {
                    break;
                    break;
                }
            }
            return;
        }// end function

        public function dealBufferMessage(param1:IBufferMessage) : void
        {
            var _loc_2:Object = null;
            switch(param1.pluginfw.nio.imsg:IBufferMessage::getCmd())
            {
                case CMDQiangHua.YJqianghua:
                {
                    ModelProxy.change("qianghua", "yijianhec", null);
                    break;
                }
                case CMDQiangHua.ITEM_QHCG:
                {
                    _loc_2 = ModelProxy.getValue("qhtips", "data");
                    if (_loc_2)
                    {
                        DialogMgr.instance.open(AppDialog.QHCGTIPS, _loc_2);
                    }
                    break;
                }
                default:
                {
                    break;
                    break;
                }
            }
            return;
        }// end function

        public function dealProxyMessage(param1:IProxyMessage) : void
        {
            return;
        }// end function

    }
}
